<?php

class Example_Atom_DocTitle
    extends OOWP_Formattable
{

    protected function getFormatPieces( )
    {
        global $wp_query;

        $site_name = get_bloginfo('name');
        $separator = '|';

        if (is_single()) {
            $content = single_post_title('', FALSE);
        } elseif (is_home() || is_front_page()) {
            $content = get_bloginfo('description');
        } elseif (is_page()) {
            $content = single_post_title('', FALSE);
        } elseif (is_search()) {
            $content = 'Search Results for:';
            $content .= ' ' . esc_html(stripslashes(get_search_query()));
        } elseif (is_category()) {
            $content = 'Category Archives:';
            $content .= ' ' . single_cat_title("", false);;
        } elseif (is_tag()) {
            $content = 'Tag Archives:';
            $content .= ' ' . thematic_tag_query();
        } elseif (is_404()) {
            $content = 'Not Found';
        } elseif (is_post_type_archive( )) {
            $obj = get_post_type_object($wp_query->query_vars['post_type']);
            $content = $obj->labels->name;
        } else {
            $content = get_bloginfo('description');
        }

        if (get_query_var('paged')) {
            $content .= ' ' . $separator . ' ';
            $content .= 'Page';
            $content .= ' ';
            $content .= get_query_var('paged');
        }

        return array(
            '<title>',
            "\t" . implode(' ', array($site_name, $separator, $content)),
            '</title>',
        );
    }

}
